home *** CD-ROM | disk | FTP | other *** search
/ Robotics & Artificial Int…3 (Professional Edition) / Robotics & Artificial Intelligence Tools 2003 (Professional Edition).iso / neural network tool and application / nsinstall.exe / data1.cab / DllSys_Files / FuzAxon / BellFuz.c next >
Encoding:
C/C++ Source or Header  |  2002-03-08  |  1.6 KB  |  52 lines

  1. // Dynamic link library implementation of NeuroSolutions Axon component
  2.  
  3. #include "NSDLL.h"
  4.  
  5. /***********************************/
  6. /* Forward activation of component */
  7.  
  8. __declspec(dllexport) void performFuzzyAxon(
  9.     DLLData    *instance,    // Pointer to instance data (may be NULL)
  10.     NSFloat    *data,         // Pointer to the layer of processing elements (PEs)
  11.     int     rows,        // Number of rows of PEs in the layer
  12.     int     cols,        // Number of columns of PEs in the layer
  13.     NSFloat    *param,     // Pointer to the layer of parameters for the MFs
  14.     int        paramIndex,    // Index into the param array
  15.     int        PEIndex,    // Index into the processing elements of the Axon
  16.                         // (the data array)
  17.     NSFloat *returnVal    // Value to return after applying the MF
  18.     )
  19. {
  20.     int baseIndex = paramIndex * 3;
  21.     NSFloat a = *(param + baseIndex);
  22.     NSFloat b = *(param + baseIndex + 1);
  23.     NSFloat c = *(param + baseIndex + 2);
  24.     if (a == 0.0f)
  25.         *returnVal = 0.0f;
  26.     else {
  27.         NSFloat tmp1 = (*(data + PEIndex) - c) / a;
  28.         NSFloat tmp2 = tmp1 == 0.0f ? 0.0f : (NSFloat)pow(tmp1*tmp1, b);
  29.         *returnVal = (1 / (1 + tmp2));
  30.     }
  31. }
  32.  
  33. /******************************************/
  34. /* Management of instance data (OPTIONAL) */
  35.  
  36. __declspec(dllexport) DLLData *allocFuzzyAxon(
  37.     DLLData    *oldInstance,    // Pointer to the last instance if reallocating
  38.     int     rows,        // Number of rows of PEs in the layer
  39.     int     cols,        // Number of columns of PEs in the layer
  40.     int        *paramCount    // Number of parameters per MF
  41.     )
  42. {
  43.     DLLData *instance = allocDLLInstance(oldInstance);
  44.     *paramCount = 3;
  45.     return instance;
  46. }
  47.  
  48. __declspec(dllexport) void freeFuzzyAxon(DLLData *instance)
  49. {
  50.     freeDLLInstance(instance);
  51. }
  52.